/*
 * @Author: intellectual-seeker 3336339701@qq.com
 * @Date: 2025-11-18 12:55:57
 * @LastEditors: intellectual-seeker 3336339701@qq.com
 * @LastEditTime: 2025-11-18 15:29:11
 * @FilePath: /code/lesson34/test1/InetAddr.hpp
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
#pragma once
#include <sys/types.h>
#include <sys/socket.h>
#include <string>
#include <arpa/inet.h>

class InetAddr
{
    void GetAddress()
    {
        _ip = inet_ntoa(_addr.sin_addr);
        _port = ntohs(_addr.sin_port);
    }
public:
    InetAddr(struct sockaddr_in addr)
        :_addr(addr)
    {
        GetAddress();
    }

    std::string Ip()
    {
        return _ip;
    }

    uint16_t Port()
    {
        return _port;
    }

    ~InetAddr()
    {}

private:
    struct sockaddr_in _addr;
    std::string _ip;
    uint16_t _port;
};
